import request from "@/utils/request";

/**
 * 新建盘点明细查询-整仓：列表查询，sku：选择商品列表查询
 */
export const searchDetail = props => {
  return request({
    url: "/mall/tenant/merchant/inventor/check/searchDetail",
    method: "post",
    data: props
  });
};

/**
 * 查询当前仓库下存在商品的分类
 */
export const getCategoriesByWarehouseId = props => {
  return request({
    url: "/mall/tenant/category/getCategoriesByWarehouseId",
    method: "get",
    params: props
  });
};
/**
 * 选择sku商品-保存临时选中数据
 */
export const saveTempSkuList = props => {
  return request({
    url: "/mall/tenant/merchant/inventor/check/saveTempSkuList",
    method: "post",
    data: props
  });
};
/**
 * 选择sku商品-查询临时选中数据
 */
export const getTempSkuList = props => {
  return request({
    url: "/mall/tenant/merchant/inventor/check/getTempSkuList",
    method: "post",
    data: props
  });
};
/**
 * 选择sku商品-移除临时选中数据
 */
export const deleteTempSku = props => {
  return request({
    url: "/mall/tenant/merchant/inventor/check/deleteTempSku",
    method: "post",
    data: props
  });
};
/**
 * 创建盘点单
 */
export const save = props => {
  return request({
    url: "/mall/tenant/merchant/inventor/check/save",
    method: "post",
    data: props
  });
};
/**
 * 盘点详情、盘点清单查询
 */
export const detailApi = props => {
  return request({
    url: `/mall/tenant/merchant/inventor/check/${props.checkId}/detail?page=${props.page}&size=${props.size}`,
    method: "get"
  });
};
/**
 * 录入
 */
export const entryApi = props => {
  return request({
    url: "/mall/tenant/merchant/inventor/check/entry",
    method: "post",
    data: props
  });
};
/**
 * 获取仓库
 */
export const getlistByTenantId = () => {
  return request({
    url: "/mall/tenant/merchant/warehouse/listByTenantId",
    method: "get"
  });
};
/**
 * 分页查询盘点单列表
 */
export const getList = data => {
  return request({
    url: "/mall/tenant/merchant/inventor/check/page",
    method: "post",
    data
  });
};
/**
 * 删除盘点单
 */
export const checkDelete = checkId => {
  return request({
    url: `/mall/tenant/merchant/inventor/check/delete/${checkId}`,
    method: "post"
  });
};
/**
 * 客户信息查询
 */
export const getCustomerInfo = props => {
  return request({
    url: `/mall/tenant/merchant/inventor/check/${props.warehouseId}/customer-info`,
    method: "get",
    params: { keyword: props.keyword }
  });
};

/**
 * 盘点导出
 */
export const checkDownload = props => {
  return request({
    url: "/mall/tenant/merchant/inventor/check/download",
    method: "get",
    params: props,
    responseType: "blob"
  });
};
